package com.wang.hello.qrcode;

import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.Result;

public class ImageResult implements Result
{
	private static final long serialVersionUID = 2918264121782772134L;
	public transient final Log logger = LogFactory.getLog(getClass());

	public void execute(ActionInvocation invocation) throws Exception {
		 
		QrCodeAction action = (QrCodeAction) invocation.getAction();
		
		HttpServletResponse response = ServletActionContext.getResponse();
 		response.setContentType(action.getContentType());
		response.getOutputStream().write(action.getQrCodeInBytes());
		response.getOutputStream().flush();
 	}
}
